<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="opener-director-objects.html" />
<link rel="prev" href="module-urllib2.html" />
<link rel="parent" href="module-urllib2.html" />
<link rel="next" href="opener-director-objects.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>18.6.1 Request Objects </title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="18.6 urllib2  "
  href="module-urllib2.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="18.6 urllib2  "
  href="module-urllib2.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="18.6.2 openerdirector Objects"
  href="opener-director-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-urllib2.html">18.6 urllib2  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-urllib2.html">18.6 urllib2  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="opener-director-objects.html">18.6.2 OpenerDirector Objects</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION0020610000000000000000"></a><a name="request-objects"></a>
<br>
18.6.1 Request Objects 
</h2>

<p>
The following methods describe all of <tt class="class">Request</tt>'s public interface,
and so all must be overridden in subclasses.

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3956' xml:id='l2h-3956' class="method">add_data</tt></b>(</nobr></td>
  <td><var>data</var>)</td></tr></table></dt>
<dd>
Set the <tt class="class">Request</tt> data to <var>data</var>.  This is ignored by all
handlers except HTTP handlers -- and there it should be a byte
string, and will change the request to be <code>POST</code> rather than
<code>GET</code>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3957' xml:id='l2h-3957' class="method">get_method</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return a string indicating the HTTP request method.  This is only
meaningful for HTTP requests, and currently always returns
<code>'GET'</code> or <code>'POST'</code>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3958' xml:id='l2h-3958' class="method">has_data</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return whether the instance has a non-<code>None</code> data.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3959' xml:id='l2h-3959' class="method">get_data</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return the instance's data.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3960' xml:id='l2h-3960' class="method">add_header</tt></b>(</nobr></td>
  <td><var>key, val</var>)</td></tr></table></dt>
<dd>
Add another header to the request.  Headers are currently ignored by
all handlers except HTTP handlers, where they are added to the list
of headers sent to the server.  Note that there cannot be more than
one header with the same name, and later calls will overwrite
previous calls in case the <var>key</var> collides.  Currently, this is
no loss of HTTP functionality, since all headers which have meaning
when used more than once have a (header-specific) way of gaining the
same functionality using only one header.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3961' xml:id='l2h-3961' class="method">add_unredirected_header</tt></b>(</nobr></td>
  <td><var>key, header</var>)</td></tr></table></dt>
<dd>
Add a header that will not be added to a redirected request.

<span class="versionnote">New in version 2.4.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3962' xml:id='l2h-3962' class="method">has_header</tt></b>(</nobr></td>
  <td><var>header</var>)</td></tr></table></dt>
<dd>
Return whether the instance has the named header (checks both regular
and unredirected).

<span class="versionnote">New in version 2.4.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3963' xml:id='l2h-3963' class="method">get_full_url</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return the URL given in the constructor.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3964' xml:id='l2h-3964' class="method">get_type</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return the type of the URL -- also known as the scheme.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3965' xml:id='l2h-3965' class="method">get_host</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return the host to which a connection will be made.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3966' xml:id='l2h-3966' class="method">get_selector</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return the selector -- the part of the URL that is sent to
the server.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3967' xml:id='l2h-3967' class="method">set_proxy</tt></b>(</nobr></td>
  <td><var>host, type</var>)</td></tr></table></dt>
<dd>
Prepare the request by connecting to a proxy server. The <var>host</var>
and <var>type</var> will replace those of the instance, and the instance's
selector will be the original URL given in the constructor.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3968' xml:id='l2h-3968' class="method">get_origin_req_host</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return the request-host of the origin transaction, as defined by
<a class="rfc" id='rfcref-102842' xml:id='rfcref-102842'
href="http://www.faqs.org/rfcs/rfc2965.html">RFC 2965</a>.  See the documentation for the <tt class="class">Request</tt>
constructor.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3969' xml:id='l2h-3969' class="method">is_unverifiable</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Return whether the request is unverifiable, as defined by RFC 2965.
See the documentation for the <tt class="class">Request</tt> constructor.
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="18.6 urllib2  "
  href="module-urllib2.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="18.6 urllib2  "
  href="module-urllib2.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="18.6.2 openerdirector Objects"
  href="opener-director-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-urllib2.html">18.6 urllib2  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-urllib2.html">18.6 urllib2  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="opener-director-objects.html">18.6.2 OpenerDirector Objects</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
